<template>
  <div class="centerbox">
    <ul class="center">
      <li class="users" @click="topersonalcenter()">
        <div class="setflex">
          <div class="headphoto"></div>
          <p v-if="loginFlag">{{user}}</p>
          <p v-else @click.stop="$router.push('/login')" class="login">登录</p>
        </div>
        <p class="iconfont setfontsize">&#xe604;</p>
      </li>

      <div class="allorders">
        <li class="allorder" @click="allorderclick()">全部订单</li>
        <li class="waitpay" @click="waitpayclick()">
          <div class="iconfont">&#xe903;</div>
          <div class="allordersright">
            <span>待付款</span>
            <p class="iconfont setfontsize">&#xe604;</p>
          </div>
        </li>
        <li class="waitpay" @click="deliverclick()">
          <div class="iconfont">&#xe8be;</div>
          <div class="allordersright">
            <span>待发货</span>
            <p class="iconfont setfontsize">&#xe604;</p>
          </div>
        </li>
        <li class="waitpay" @click="harvestclick()">
          <div class="iconfont">&#xe640;</div>
          <div class="allordersright">
            <span>待收货</span>
            <p class="iconfont setfontsize">&#xe604;</p>
          </div>
        </li>
        <li class="waitpay" @click="commentclick()">
          <div class="iconfont">&#xe8f7;</div>
          <div class="allordersright">
            <span>待评论</span>
            <p class="iconfont setfontsize">&#xe604;</p>
          </div>
        </li>
        <li class="waitpay" @click="returnedclick()">
          <div class="iconfont">&#xe911;</div>
          <div class="allordersright">
            <span>退换货</span>
            <p class="iconfont setfontsize">&#xe604;</p>
          </div>
        </li>
      </div>
      <div class="myserve">
        <li @click="collectclick()">
          <p class="fourteenfont">我的收藏</p>
          <p class="iconfont setfontsize">&#xe604;</p>
        </li>
        <li @click="couponsclick()">
          <p class="fourteenfont">我的礼卷</p>
          <p class="iconfont setfontsize">&#xe604;</p>
        </li>
        <li>
          <p class="fourteenfont">客服电话</p>
          <div>
            <span>周一至周日 9:00-21:00</span>
            <p class="iconfont setfontsize">&#xe604;</p>
          </div>
        </li>
      </div>
      <li class="quit" v-show="loginFlag" @click="quit">退出登录</li>
    </ul>
  </div>
</template>
<script>
import Vue from 'vue'
import { Collapse, CollapseItem } from 'vant'
import { mapState, mapMutations } from 'vuex'

Vue.use(Collapse)
Vue.use(CollapseItem)
export default {
  data () {
    return {
      activeNames: ['1'],
      user: true
    }
  },
  mounted () {
    this.user = localStorage.getItem('user')
    this.setLoginFLag(Boolean(this.user))
  },
  methods: {
    ...mapMutations('user', ['setLoginFLag']),
    showPopup () {
      this.show = true
    },
    // 跳转到个人信息
    topersonalcenter () {
      this.$router.push('/center/usermassage')
    },
    allorderclick () {
      this.$router.push('/center/myorder/all')
    },
    waitpayclick () {
      this.$router.push('/center/myorder/waitpay')
    },
    deliverclick () {
      this.$router.push('/center/myorder/deliver')
    },
    harvestclick () {
      this.$router.push('/center/myorder/harvest')
    },
    commentclick () {
      this.$router.push('/center/myorder/comment')
    },
    returnedclick () {
      this.$router.push('/center/myorder/returned')
    },
    collectclick () {
      this.$router.push('/center/collect/oneproducte')
    },
    couponsclick () {
      this.$router.push('/center/coupons')
    },
    quit () {
      localStorage.removeItem('user')
      this.user = localStorage.getItem('user')
      this.setLoginFLag(Boolean(this.user))
    }
  },
  computed: {
    ...mapState('user', ['loginFlag'])
  }
}
</script>
<style lang="scss" scoped>
.setflex {
  display: flex;
}
.setfontsize {
  font-size: 30px;
  color: #cccccc;
  margin-right: 10px;
}
.fourteenfont {
  font-size: 14px;
}
.centerbox {
  width: 100%;
  height: 100%;
  background: #ececec;
  margin-bottom: 60px;
  position: relative;
  .center {
    li {
      display: flex;
      justify-content: space-between;
      background-color: #ffffff;
      align-items: center;
      div {
        display: flex;
        align-items: center;
      }
    }
    .users {
      padding: 10px 0 10px 10px;
      .headphoto {
        border-radius: 50%;
        width: 50px;
        height: 50px;
        background: #cccccc;
        text-align: center;
      }
      .setflex {
        display: flex;
        align-items: center;
        p {
          margin-left: 20px;
        }
        .login{
          position: absolute;
          top: 23px;
          left: 53px;
        }
      }
    }
    .allorders {
      margin-top: 10px;
      background-color: #ffffff;
      box-sizing: border-box;
      padding: 0 0 0 20px;
      .allorder {
        padding: 10px 0 10px 0;
        font-size: 14px;
        border-bottom: 1px solid #e7e7e7;
      }
      .waitpay {
        .allordersright {
          width: 90%;
          display: flex;
          justify-content: space-between;
          border-bottom: 1px solid #e7e7e7;
          padding: 10px 0 10px 0;
          span {
            font-size: 12px;
          }
        }
      }
    }
    .myserve {
      margin-top: 10px;
      background-color: #ffffff;
      li {
        padding: 12px 0 12px 15px;
        border-bottom: 1px solid #e7e7e7;
        span {
          font-size: 12px;
          color: #cccccc;
        }
      }
    }
    .quit {
      display: flex;
      justify-content: center;
      margin-top: 10px;
      padding: 12px 0 12px 0;
      color: #f16e6e;
    }
  }
}
</style>
